<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>学生信息添加</title>
    <link rel="stylesheet" href="layui-v2.5.7/layui/css/layui.css" />
</head>

<body style="padding:20px">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>添加学生</legend>
    </fieldset>
    <form class="layui-form" action=" " lay-filter="formUpdate">
        <div class="layui-form-item">
            <label class="layui-form-label">学生编号</label>
            <div class="layui-input-block">
                <input type="text" name="stuId"  lay-verify="title" autocomplete="off"
                     class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">学生姓名</label>
            <div class="layui-input-block">
                <input type="text" name="stuName" lay-verify="title" autocomplete="off" 
                    class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">性别</label>
            <div class="layui-input-block">
                <input type="text" name="stuSex" lay-verify="title" autocomplete="off" 
                    class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">年龄</label>
            <div class="layui-input-block">
                <input type="text" name="stuAge" lay-verify="title" autocomplete="off" 
                    class="layui-input">
            </div>
        </div>


        <div class="layui-inline">
            <label class="layui-form-label">电话</label>
            <div class="layui-input-block">
                <input type="text" name="stuTel" lay-verify="title" autocomplete="off" 
                    class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">邮件</label>
            <div class="layui-input-block">
                <input type="text" name="stuMail" lay-verify="title" autocomplete="off" 
                    class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">职位</label>
            <div class="layui-input-block">
                <input type="text" name="stuMaster" lay-verify="title" autocomplete="off" 
                    class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">账号</label>
            <div class="layui-input-block">
                <input type="text" name="stuAccount" lay-verify="title" autocomplete="off" 
                    class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码</label>
            <div class="layui-input-block">
                <input type="text" name="stuPsw" lay-verify="title" autocomplete="off" 
                    class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">入学日期</label>
            <div class="layui-input-inline">
                <input type="text" name="stuHiredate" id="date" lay-verify="date" 
                    autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">角色</label>
            <div class="layui-input-block">
                <input type="text" name="stuRole" lay-verify="title" autocomplete="off" 
                    class="layui-input">
            </div>
        </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn" lay-submit="" lay-filter="submitStu">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>

    <script type="text/javascript" src="layui-v2.5.7/layui/layui.js"></script>
    <script>
        layui.use(['layer', 'laydate', 'form', 'jquery'], function () {
            var layer = layui.layer;
            var laydate = layui.laydate;
            var form = layui.form;
            var $ = layui.jquery

            //日期
            laydate.render({
                elem: '#date'
            });


            form.render();

           //监听提交
	  form.on('submit(submitStu)', function(data){
	   /*  layer.alert(JSON.stringify(data.field), {
	    }) */
	    $.ajax({
	    	url:'http://localhost:8080/addStu',
	    	type:'POST',
	    	dataType:'JSON',
	    	data:data.field,
	    	success:function(result){
	    		
	    		//关闭窗口
	    		//当你在iframe页面关闭自身时
	    		  var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
				  parent.layer.close(index); //再执行关闭   
				  //刷新列表
				  parent.table.reload("Student");
	    	}
	    })
	    //避免from的默认提交动作(刷新页面)
	    return false;
	  });
});
    </script>
</body>

</html>